package org.kisekiproject.course {
	import flash.display.Stage;
	
	import org.kisekiproject.log.Log;

	/**
	 * Course config.
	 */
	public class CourseConfig {

		private var _width:int;
		private var _height:int;
		private var _persistence:String;
		private var _debug:Boolean;
		private var _autosaveInterval:int;

		/**
		 * Constructor.
		 */
		public function CourseConfig() {
			_width=800;
			_height=600;
			_debug=false;
			_autosaveInterval=30;
		}

		/**
		 * Parse.
		 */
		public function parse(source:XML):void {
			Log.debug("parsing config...");

			for each (var x:XML in source.children()) {
				var key:String=String(x.name());
				var value:String=String(x);

				Log.debug("  config: "+key+"="+value);

				switch (key) {
					case "width":
						_width=new Number(value);
						break;
					
					case "height":
						_height=new Number(value);
						break;

					case "persistence":
						_persistence=value;
						break;

					case "debug":
						_debug=true;
						break;

					case "autosaveinterval":
						_autosaveInterval=new int(value);
						break;

					default:
						throw new Error("Unknown config option: "+key);
						break;
				}
			}
		}

		
		/**
		 * Get width.
		 */
		public function get width():int {
			return _width;
		}

		/**
		 * Get height.
		 */
		public function get height():int {
			return _height;
		}

		/**
		 * Get persistance.
		 */
		public function get persistence():String {
			return _persistence;
		}

		/**
		 * Debug?
		 */
		public function get debug():Boolean {
			return _debug;
		}

		/**
		 * Get autosave interval.
		 */
		public function get autosaveInterval():int {
			return _autosaveInterval;
		}

	}
}